package com.wuyou.mid;

public class MinDeletion {

    public static void main(String[] args) {
//        int[] nums = {1,1,2,3,5};
//        int[] nums = {1, 1, 2, 2, 3, 3};
        int[] nums = {0, 1, 5, 4, 2, 4, 7, 2, 3, 0, 3, 0, 0, 9, 7, 5, 9, 4, 3, 9, 9, 2,
                1, 6, 3, 1, 0, 7, 6, 6, 6, 0, 1, 7, 1, 9, 4, 9, 3, 3, 4, 5, 0, 3, 8, 7,
                1, 8, 4, 5};


        System.out.println(solution_1(nums));
    }

    public static int solution_1(int[] nums) {
        int ans = 0, index = 0, next, flag = 0;
        while (index < nums.length - 1) {
            next = nums[index + 1];
            if ((index - flag) % 2 == 0 && nums[index] == next) {
                ans++;
                if (flag == 0) {
                    flag = 1;
                } else {
                    flag = 0;
                }
            }
            index++;
        }
        if ((nums.length - ans) % 2 != 0) {
            ans++;
        }
        return ans;
    }
}